//
//  main.c
//  C_1
//
//  Created by GuoRobin on 16/3/15.
//  Copyright © 2016年 Eli. All rights reserved.
//

#include <stdio.h>

int j = 4;

typedef struct Location{
    
    float lati; // 精度
    float lon;  // 纬度
    
}location;

location go_south (float *lat ,float *lon){
    
    *lat -= 1.0;
    *lon += 2.0;
    location currentLocation = {*lat,*lon};
    return currentLocation;
}

void funturn_code (char msg[]);

void text_Scanf();  // 测试scanf

void text_fgets();  // 测试 fgets

void skip(char *msg);

int main(int argc, const char * argv[]) {
    // insert code here...
//    printf("Hello, World!\n");
    
//    int i = 4;
//    int k = 5;
//    
//    printf("x 的地址是%p 在函数内 栈区(Stack)\n j的地址是 %p 全局量区\n k的地址是%p\n",&i,&j,&k);
    
    float lat = -34.00;
    float lon = 65.00;
    
    //text_Scanf();
    text_fgets();
    
    location currentLocation = go_south(&lat,&lon);
    
    printf("currentlocation is lat %f lon %f\n",currentLocation.lati,currentLocation.lon);
    
    char msg[] = "my name is Robin\n";
    
    char *t = msg;
    
    printf("sizeof message is :%s\n",msg);
    printf("address of t : %s\n",t);
    
    funturn_code(msg);
    
    char *msg_from_amy = "Don't call me later!";
    skip(msg_from_amy);
    
    int doses[] = {1,2,3,1000};
    
    printf("服用 %i 毫克的药\n",3[doses]);
    printf("address of doses : %p\n",doses);
    
    //doses[3] == *(doses+3) == *(3+doses) == 3[doses];
    
    
    return 0;
}

void skip(char *msg){
    printf("skip word is: %s\n",msg+6);
    puts(msg+6);
}

void text_fgets(){
    char food[5];
    fgets(food, sizeof(food), stdin);
    
    printf("my favourite food is %s\n",food);
}

void text_Scanf(){
    char first_name[5];
    char last_name[5];
    printf("Enter first name and last name:");
    scanf("%5s %5s",first_name,last_name);
    printf("first : %s last : %s \n",first_name,last_name);
}

void funturn_code (char *msg){
    
    printf("message read : %c\n",*msg);
    printf("message occupied : %lu bytes \n",sizeof(msg));
}
